#include<stdio.h>
main() 
{
	int x,y,head,foot;
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{ 
	printf("请输入鸡兔总头数和总脚数：");
	scanf("%d %d",&head,&foot);
	y=(foot-2*head)/2;
	x=head-y;
	if(x>0&&y>0)
	{
	   printf("鸡和兔的数目分别为：%d %d\n",x,y);
    }
    else
    printf("error\n");
    }
	return 0;
}
 
